"""SxShop3 URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path, include
from rest_framework.documentation import include_docs_urls

from django.views.static import serve
from SxShop3.settings import MEDIA_ROOT
from rest_framework_jwt.views import obtain_jwt_token

from rest_framework.routers import DefaultRouter
router = DefaultRouter()
from goods.views import *
from users.views import *
from user_operation.views import *
from trade.views import *


# 商品列表路由
router.register('goods', GoodsListView, base_name='goods')

# 分类路由
router.register('categorys', CategoryViewset, base_name='categorys')

# 发验证码
router.register('codes', SmsCodeViewset, base_name='codes')

# 注册路由
router.register('users', UserRegViewset, base_name='users')

# 注册路由
router.register('userfavs', UserFavViewset, base_name='userfavs')

# 热搜词路由
router.register("hotsearchs", HotSearchViewset, base_name="hotsearchs")

# 用户留言
router.register("messages", LeavingMessageViewset, base_name="messages")

# 收货地址路由
router.register("address", AddressViewset, base_name="address")

# 购物车路由
router.register("shopcarts", ShoppingCartViewset, base_name="shopcarts")

# 订单路由
router.register("orders", OrderViewset, base_name="orders")

# # 轮播图
# router.register("banners", BannerViewset, base_name="banners")
#
# # 首页商品系列数据
# router.register("indexgoods", IndexGoodsViewset, base_name="indexgoods")


from django.views.generic import TemplateView


urlpatterns = [
    path('admin/', admin.site.urls),

    # 静态文件路由01
    re_path(r'^media/(?P<path>.*)/$', serve, {'document_root': MEDIA_ROOT}),

    # 找到子路由
    path('', include(router.urls)),

    # 登陆路由
    re_path(r'^login', obtain_jwt_token),

    # 文档路由
    path('docs/', include_docs_urls(title='天天生鲜')),

    # 支付结果处理路由
    re_path(r"^alipay/return", AlipayView.as_view(), name="alipay"),

    # 给模板配路由
    path('index/', TemplateView.as_view(template_name='index.html'), name='index'),
]







